package com.ruoyi.system.mapper;

import java.util.List;

import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.system.domain.ByBs;
import com.ruoyi.system.domain.vo.ByBsVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * 帮手Mapper接口
 *
 * @author ruoyi
 * @date 2023-05-16
 */
public interface ByBsMapper {
    @Select("SELECT * FROM `by_bs` where `status` = '0' and wxid = #{wxid}")
    List<ByBs> getBsListByWxid(@Param("wxid") String wxid);

    @Select("SELECT * FROM `by_bs` where `status` = '1' and wxid = #{wxid} ORDER BY addtime DESC LIMIT 0,1")
    JSONObject getBsByWxid(@Param("wxid") String wxid);

    @Select("SELECT hprice,mprice FROM `by_bs` where id = #{id}")
    JSONObject getBsPrice(@Param("id") String id);

    @Update("update by_bs set status = #{status} where id = #{id}")
    int upBsStatus(@Param("id") String id,@Param("status") String status);

    @Select("SELECT id,`name`,img,CONCAT(ordercount,'次') ordercount,CONCAT(discount,'评价') discount FROM `by_bs` where `status`=1  order by RAND() limit 0,9")
    List<ByBs> pageBangshouIndexShow();

    @Select("select * from by_bs where id = #{id}")
    JSONObject bsDetailById(@Param("id") String id);

    @Select("SELECT id,`name`,img,CONCAT(ordercount,'次') ordercount,CONCAT(discount,'评价') discount FROM `by_bs` where `status`=1 and school_id in (#{schoolSql}) order by addtime desc limit #{page},10")
    List<ByBs> pageBangshou_school(@Param("schoolSql") String schoolSql,@Param("page") int page);

    @Select("SELECT id,`name`,img,CONCAT(ordercount,'次') ordercount,CONCAT(discount,'评价') discount FROM `by_bs` where `status`=1  order by addtime desc limit #{page},10")
    List<ByBs> pageBangshou(@Param("page") int page);

    @Select("SELECT * FROM `by_bs` where wxid = #{wxid} order by addtime desc limit 0,1")
    ByBs queryByWxid(@Param("wxid") String wxid);

    //根据证件号码判断当前帮手是否存在
    @Select("SELECT * FROM `by_bs` where cardno = #{cardno}")
    List<ByBs> queryCountByCardNo(@Param("cardno") String cardno);


    List<ByBs> searchWxPage(ByBsVo bsVo);

    /**
     * 查询帮手
     *
     * @param id 帮手主键
     * @return 帮手
     */
    public ByBs selectByBsById(Long id);

    /**
     * 查询帮手列表
     *
     * @param byBs 帮手
     * @return 帮手集合
     */
    public List<ByBs> selectByBsList(ByBs byBs);

    /**
     * 新增帮手
     *
     * @param byBs 帮手
     * @return 结果
     */
    public int insertByBs(ByBs byBs);

    /**
     * 修改帮手
     *
     * @param byBs 帮手
     * @return 结果
     */
    public int updateByBs(ByBs byBs);

    /**
     * 删除帮手
     *
     * @param id 帮手主键
     * @return 结果
     */
    public int deleteByBsById(Long id);

    /**
     * 批量删除帮手
     *
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteByBsByIds(Long[] ids);
}
